package corej.course.gui;

import javax.swing.*;
import java.awt.*;

public class TestCardLayout {
    public static void main(String[] args) throws Exception {
        JFrame frame = new JFrame("MyFrame");
        frame.setSize(500, 300);

        CardLayout m = new CardLayout();
        frame.setLayout(m);

        JPanel p1 = new JPanel();
        p1.setBackground(Color.BLUE);
        JPanel p2 = new JPanel();
        p2.setBackground(Color.PINK);
        JPanel p3 = new JPanel();
        p3.setBackground(Color.YELLOW);
        JPanel p4 = new JPanel();
        p4.setBackground(Color.RED);

        frame.add(p1, "Panel1");
        frame.add(p2, "Panel2");
        frame.add(p3, "Panel3");
        frame.add(p4, "Panel4");

        frame.setVisible(true);

        for (int i = 1; i <= 10; i++) {
            Thread.sleep(1000);
            m.next(frame.getContentPane());
        }

        m.show(frame.getContentPane(), "Panel4");

    }
}
